package com.example.fill.output;

import java.io.FileWriter;
import java.io.IOException;
import java.util.List;

public class CsvType extends TxtType{

    @Override
    public void initTitle(FileWriter page, List<String> rowData) {
        for (String rowDatum : rowData) {
            try {
                page.write(rowDatum+",");
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        try {
            page.write("\n");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public void initBody(FileWriter page, int yIndex, List<String> rowData) {
        for (String rowDatum : rowData) {
            try {
                page.write(rowDatum+",");
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        try {
            page.write("\n");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    String getType() {
        return ".csv";
    }
}
